package com.OnTimeTeam.OnTime;

import java.util.ArrayList;
import java.util.concurrent.TimeUnit;

import android.content.Context;
import android.media.MediaPlayer;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class TunePickerAdapter extends ArrayAdapter<Boolean> {

	private ArrayList<Boolean> playerArray; //all alarms details
	private ArrayList<Integer> durationsLong; //


	///////////////
	//CTOR - init' the array of AlarmFeatures and ApplicationContext object
	public TunePickerAdapter(Context context, int textViewResourceId, ArrayList<Boolean> playerArray) {
		super(context, textViewResourceId, playerArray);
		this.playerArray = playerArray;
	}

	////////////////////
	//This method sets the view of ONE item in the list (it gets it's index - it's the same index as the AlarmFeatures ArrayList)
	public View getView(final int index, View convertView, ViewGroup parent) {
	
		View view = convertView;
		LayoutInflater inflater = null;
		
		if (view == null) {
			inflater = (LayoutInflater)this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			view = inflater.inflate(R.layout.tune_line, null);//set the view
		}
		
		TextView entry = (TextView)view.findViewById(R.id.choiceItem);
		ImageView currentImage = (ImageView)view.findViewById(R.id.itemImage); 
		currentImage.setFocusable(false);
		currentImage.setClickable(false);
		entry.setFocusable(false);
		
		if(!playerArray.get(index))
			currentImage.setImageResource(R.drawable.play_button);
		else
			currentImage.setImageResource(R.drawable.stop_button);
		
		
		switch(index){
		
		
			case 0:
				entry.setText("Alarm I");
				break;
			case 1:
				entry.setText("Alarm II");
				break;
			case 2:
				entry.setText("Alarm III");
				break;
			case 3:
				entry.setText("Alarm IV");
				break;
			case 4:
				entry.setText("Alarm V");
				break;
			case 5:
				entry.setText("Alarm VI");
				break;
				
		}//end of switch-cases

		
		//return the view of the item
		return view;
	
	}//end of method 'getView'
	
}
	